/*
** get_line.c for corewar in /home/boulah_m/corewar
**
** Made by moustafa boulahia
** Login   <boulah_m@epitech.net>
**
** Started on  Tue Feb  7 14:36:46 2012 moustafa boulahia
** Last update Thu Feb 16 11:06:29 2012 moustafa boulahia
*/
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "my.h"

char	*get_line(int fd)
{
  char	*tmp;
  static int i;

  tmp = malloc(4096);
  if (tmp != NULL)
    {
      read(fd, tmp, 4096);
      i = 0;
      while (tmp[i] != '\n' && i <= 4096 && tmp[i] != '\0')
	{
	  i++;
	}
      if (tmp[i] == '\0')
	return (NULL);
      else
	{
	  lseek(fd ,SEEK_SET, i);
	  return (tmp);
	}
    }
  else
    return (NULL);
}
